class Solution(object):
    def generate(self, numRows):
        """
        :type numRows: int
        :rtype: List[List[int]]
        """
        result = []
        lastRow = []
        for length in range(1, numRows+1):
            row = [0 for _ in range(length)]
            row[0]=1
            row[-1]=1
            for i in range(1, length-1):
                row[i] = lastRow[i]+lastRow[i-1]
            result.append(row)
            lastRow = row
        return result

print(Solution().generate(0))